/*     */ package cn.zzuisa.news.repository.dao;

/*     */
/*     */ import cn.zzuisa.news.entity.News;
/*     */ import cn.zzuisa.news.entity.Page;
/*     */ import cn.zzuisa.news.form.NewsEditForm;
/*     */ import cn.zzuisa.news.form.NewsForm;
/*     */ import cn.zzuisa.news.repository.NewsRepository;
/*     */ import cn.zzuisa.news.util.JDBCUtil;
/*     */ import java.sql.Connection;
/*     */ import java.sql.PreparedStatement;
/*     */ import java.sql.ResultSet;
/*     */ import java.sql.SQLException;
/*     */ import java.sql.Statement;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;

/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */ public class NewsDAO implements NewsRepository

/*     */ {
	Connection conn = null;
	Statement statement = null;
	ResultSet resultSet = null;
	PreparedStatement preparedStatement = null;

	/*     */ public List<News> list() {
		/* 29 */ conn = JDBCUtil.getConnection();
		/* 30 */ statement = null;
		/* 31 */ resultSet = null;
		/* 32 */ String sql = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from `news_info` order by news_id desc";
		/*     */ try {
			/* 34 */ statement = conn.createStatement();
			/* 35 */ resultSet = statement.executeQuery(sql);
			/* 36 */ List<News> newslist = new ArrayList<News>();
			/* 37 */ while (resultSet.next()) {
				/* 38 */ News news = new News();
				/* 39 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/* 40 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 41 */ news.setNewsName(resultSet.getString("news_name"));
				/* 42 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 43 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 44 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 45 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 46 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 47 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 48 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 49 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 50 */ newslist.add(news);
				/*     */ }
			/* 52 */ return newslist;
			/*     */ }
		/* 54 */ catch (SQLException e) {
			/*     */
			/* 56 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 59 */ JDBCUtil.close(conn, statement, resultSet);
				/* 60 */ } catch (Exception e) {
				/*     */
				/* 62 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 65 */ return null;
		/*     */ }

	/*     */
	/*     */
	/*     */ public boolean add(NewsForm newsForm) {
		/* 70 */ conn = JDBCUtil.getConnection();
		/* 71 */ preparedStatement = null;
		/* 72 */ ResultSet resultSet = null;
		/* 73 */ int flag = 0, flag2 = 0;
		/* 74 */ int latestId = 0, latestId2 = 0;
		/* 75 */ String sqlOfnews_info = "insert into `news_info` (news_name,u_id,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del) values(?,?,?,?,?,?,?,?,?)";
		/* 76 */ String sql = "select max(news_id) news_id from news_info ";
		/* 77 */ String sql2 = "select max(id) id from news_info_type ";
		/* 78 */ String sqlOfnews_type = "insert into `news_info_type` (news_id,type_id) values (?,?)";
		/*     */
		/*     */ try {
			/* 81 */ preparedStatement = conn.prepareStatement(sql);
			/* 82 */ resultSet = preparedStatement.executeQuery();
			/* 83 */ while (resultSet.next()) {
				/* 84 */ latestId = resultSet.getInt("news_id");
				/*     */ }
			/* 86 */ preparedStatement = conn.prepareStatement(sql2);
			/* 87 */ resultSet = preparedStatement.executeQuery();
			/* 88 */ while (resultSet.next()) {
				/* 89 */ latestId2 = resultSet.getInt("id");
				/*     */ }
			/*     */
			/* 92 */ preparedStatement = conn.prepareStatement(sqlOfnews_info);
			/* 93 */ preparedStatement.setString(1, newsForm.getNewsName());
			/* 94 */ preparedStatement.setInt(2, newsForm.getuId().intValue());
			/* 95 */ preparedStatement.setString(3, newsForm.getNewsAuthor());
			/* 96 */ preparedStatement.setString(4, newsForm.getNewsContent());
			/* 97 */ preparedStatement.setInt(5, latestId2 + 1);
			/* 98 */ preparedStatement.setString(6, newsForm.getNewsKeywords());
			/* 99 */ preparedStatement.setInt(7, 0);
			/* 100 */ preparedStatement.setInt(8, 0);
			/* 101 */ preparedStatement.setInt(9, 0);
			/* 102 */ flag = preparedStatement.executeUpdate();
			/*     */
			/* 104 */ preparedStatement = conn.prepareStatement(sqlOfnews_type);
			/* 105 */ System.out.println("index:" + newsForm.getNewsType().toString());
			/* 106 */ for (String item : newsForm.getNewsType()) {
				/* 107 */ preparedStatement.setInt(1, latestId + 1);
				/* 108 */ preparedStatement.setInt(2, Integer.parseInt(item));
				/* 109 */ flag2 = preparedStatement.executeUpdate();
				/*     */ }
			/*     */
			/* 112 */ } catch (SQLException e) {
			/*     */
			/* 114 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 117 */ JDBCUtil.close(conn, preparedStatement);
				/* 118 */ } catch (Exception e) {
				/*     */
				/* 120 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 123 */ return (flag + flag2 > 1);
		/*     */ }

	/*     */
	/*     */
	/*     */
	/*     */ public News findById(Integer id) {
		/* 129 */ conn = JDBCUtil.getConnection();
		/* 130 */ statement = null;
		/* 131 */ resultSet = null;
		/* 132 */ int flag = 0;
		/* 133 */ String sql = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from `news_info` where news_id = "
				+
				/* 134 */ id;
		/* 135 */ News news = new News();
		/*     */ try {
			/* 137 */ statement = conn.createStatement();
			/* 138 */ resultSet = statement.executeQuery(sql);
			/* 139 */ if (resultSet.next()) {
				/* 140 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 141 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 142 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 143 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 144 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 145 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 146 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 147 */ news.setNewsName(resultSet.getString("news_name"));
				/* 148 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 149 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 150 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/*     */ }
			/* 152 */ } catch (SQLException e) {
			/*     */
			/* 154 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 157 */ JDBCUtil.close(conn, statement, resultSet);
				/* 158 */ } catch (Exception e) {
				/*     */
				/* 160 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 163 */ return news;
		/*     */ }

	/*     */
	/*     */
	/*     */ public List<News> listpass() {
		/* 168 */ conn = JDBCUtil.getConnection();
		/* 169 */ statement = null;
		/* 170 */ resultSet = null;
		/* 171 */ String sql = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from `news_info` where news_state = 1 order by news_click desc";
		/*     */ try {
			/* 173 */ statement = conn.createStatement();
			/* 174 */ resultSet = statement.executeQuery(sql);
			/* 175 */ List<News> newslist = new ArrayList<News>();
			/* 176 */ while (resultSet.next()) {
				/* 177 */ News news = new News();
				/* 178 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/* 179 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 180 */ news.setNewsName(resultSet.getString("news_name"));
				/* 181 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 182 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 183 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 184 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 185 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 186 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 187 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 188 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 189 */ newslist.add(news);
				/*     */ }
			/* 191 */ return newslist;
			/*     */ }
		/* 193 */ catch (SQLException e) {
			/*     */
			/* 195 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 198 */ JDBCUtil.close(conn, statement, resultSet);
				/* 199 */ } catch (Exception e) {
				/*     */
				/* 201 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 204 */ return null;
		/*     */ }

	/*     */
	/*     */
	/*     */
	/*     */ public boolean setState(Integer state, Integer id) {
		/* 210 */ conn = JDBCUtil.getConnection();
		/* 211 */ preparedStatement = null;
		/* 212 */ int flag = 0;
		/* 213 */ String sql = "UPDATE `news_info` SET news_state=? where news_id = ?";
		/*     */ try {
			/* 215 */ preparedStatement = conn.prepareStatement(sql);
			/* 216 */ preparedStatement.setInt(1, state.intValue());
			/* 217 */ preparedStatement.setInt(2, id.intValue());
			/* 218 */ flag = preparedStatement.executeUpdate();
			/* 219 */ } catch (SQLException e) {
			/*     */
			/* 221 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 224 */ JDBCUtil.close(conn, preparedStatement);
				/* 225 */ } catch (Exception e) {
				/*     */
				/* 227 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 230 */ return (flag > 0);
		/*     */ }

	/*     */
	/*     */
	/*     */ public Page page(Integer current, Integer size, String sql) {
		/* 235 */ conn = JDBCUtil.getConnection();
		/* 236 */ preparedStatement = null;
		/* 237 */ resultSet = null;
		/* 238 */ Page page = null;
		/* 239 */ sql = (sql == null) ? "" : sql;
		/* 240 */ System.out.println("sqllll" + sql);
		/* 241 */ String sql1 = "select count(news_id) from news_info where " + sql + " 1=1";
		/* 242 */ String sql2 = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from `news_info` where "
				+
				/* 243 */ sql +
				/* 244 */ " 1=1 order by news_id desc limit ?,? ";
		/*     */ try {
			/* 246 */ int totalCount = 0;
			/* 247 */ preparedStatement = conn.prepareStatement(sql1);
			/* 248 */ resultSet = preparedStatement.executeQuery();
			/* 249 */ while (resultSet.next()) {
				/* 250 */ totalCount = resultSet.getInt(1);
				/*     */ }
			/* 252 */ preparedStatement = conn.prepareStatement(sql2);
			/* 253 */ preparedStatement.setInt(1, (current.intValue() - 1) * size.intValue());
			/* 254 */ preparedStatement.setInt(2, size.intValue());
			/* 255 */ resultSet = preparedStatement.executeQuery();
			/*     */
			/* 257 */ List<News> newslist = new ArrayList<News>();
			/* 258 */ while (resultSet.next()) {
				/* 259 */ News news = new News();
				/* 260 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/* 261 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 262 */ news.setNewsName(resultSet.getString("news_name"));
				/* 263 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 264 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 265 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 266 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 267 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 268 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 269 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 270 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 271 */ newslist.add(news);
				/*     */ }
			/* 273 */ page = new Page(size.intValue(), totalCount);
			/* 274 */ page.setData(newslist);
			/*     */ }
		/* 276 */ catch (SQLException e) {
			/*     */
			/* 278 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 281 */ JDBCUtil.close(conn, preparedStatement, resultSet);
				/* 282 */ } catch (Exception e) {
				/*     */
				/* 284 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 287 */ return page;
		/*     */ }

	/*     */
	/*     */
	/*     */
	/*     */
	/* 293 */ public Page pagelist(Integer current, Integer size) {
		return null;
	}

	/*     */
	/*     */
	/*     */
	/*     */ public Page ListByTypesName(Integer current, Integer size, String name, String sql) {
		/* 298 */ conn = JDBCUtil.getConnection();
		/* 299 */ preparedStatement = null;
		/* 300 */ resultSet = null;
		/* 301 */ Page page = null;
		/* 302 */ sql = (sql == null) ? "" : sql;
		/* 303 */ System.out.println(sql);
		/* 304 */ System.out.println("sqlllbname+" + name);
		/* 305 */ String sql1 = "select count(news_id) from news_info where " + sql + " news_id in " +
		/* 306 */ "(select news_id from news_info_type where type_id in" +
		/* 307 */ "(select type from news_type where name = ?))";
		/*     */
		/* 309 */ String sql2 = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from news_info where "
				+
				/* 310 */ sql + " news_id in " +
				/* 311 */ "(select news_id from news_info_type where type_id in" +
				/* 312 */ "(select type from news_type where name = ?)) order by news_id desc limit ?,?";
		/*     */ try {
			/* 314 */ int totalCount = 0;
			/* 315 */ preparedStatement = conn.prepareStatement(sql1);
			/* 316 */ preparedStatement.setString(1, name);
			/* 317 */ resultSet = preparedStatement.executeQuery();
			/* 318 */ while (resultSet.next()) {
				/* 319 */ totalCount = resultSet.getInt(1);
				/*     */ }
			/* 321 */ System.out.println("totaoCount:" + totalCount);
			/* 322 */ preparedStatement = conn.prepareStatement(sql2);
			/* 323 */ preparedStatement.setString(1, name);
			/* 324 */ preparedStatement.setInt(2, (current.intValue() - 1) * size.intValue());
			/* 325 */ preparedStatement.setInt(3, size.intValue());
			/* 326 */ resultSet = preparedStatement.executeQuery();
			/*     */
			/* 328 */ List<News> newslist = new ArrayList<News>();
			/* 329 */ while (resultSet.next()) {
				/* 330 */ News news = new News();
				/* 331 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/* 332 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 333 */ news.setNewsName(resultSet.getString("news_name"));
				/* 334 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 335 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 336 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 337 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 338 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 339 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 340 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 341 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 342 */ newslist.add(news);
				/*     */ }
			/* 344 */ page = new Page(size.intValue(), totalCount);
			/* 345 */ page.setData(newslist);
			/*     */ }
		/* 347 */ catch (SQLException e) {
			/*     */
			/* 349 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 352 */ JDBCUtil.close(conn, preparedStatement, resultSet);
				/* 353 */ } catch (Exception e) {
				/*     */
				/* 355 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 358 */ return page;
		/*     */ }

	/*     */
	/*     */
	/*     */ public Page search(Integer current, Integer size, String keyWords, String sql) {
		/* 363 */ conn = JDBCUtil.getConnection();
		/* 364 */ preparedStatement = null;
		/* 365 */ resultSet = null;
		/* 366 */ Page page = null;
		/* 367 */ sql = (sql == null) ? "" : sql;
		/* 368 */ System.out.println(sql);
		/* 369 */ System.out.println("keyWords:" + keyWords);
		/* 370 */ String sql1 = "select count(news_id) from news_info where " + sql +
		/* 371 */ " news_name like ? or news_content like ? or news_keywords like ?";
		/*     */
		/* 373 */ String sql2 = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from news_info where "
				+
				/* 374 */ sql +
				/* 375 */ " news_name like ? or news_content like ? or news_keywords like ? order by news_id desc limit ?,?";
		/*     */ try {
			/* 377 */ int totalCount = 0;
			/* 378 */ preparedStatement = conn.prepareStatement(sql1);
			/* 379 */ preparedStatement.setString(1, "%" + keyWords + "%");
			/* 380 */ preparedStatement.setString(2, "%" + keyWords + "%");
			/* 381 */ preparedStatement.setString(3, "%" + keyWords + "%");
			/* 382 */ resultSet = preparedStatement.executeQuery();
			/* 383 */ while (resultSet.next()) {
				/* 384 */ totalCount = resultSet.getInt(1);
				/*     */ }
			/* 386 */ System.out.println("totaoCount:" + totalCount);
			/* 387 */ preparedStatement = conn.prepareStatement(sql2);
			/* 388 */ preparedStatement.setString(1, "%" + keyWords + "%");
			/* 389 */ preparedStatement.setString(2, "%" + keyWords + "%");
			/* 390 */ preparedStatement.setString(3, "%" + keyWords + "%");
			/* 391 */ preparedStatement.setInt(4, (current.intValue() - 1) * size.intValue());
			/* 392 */ preparedStatement.setInt(5, size.intValue());
			/* 393 */ resultSet = preparedStatement.executeQuery();
			/*     */
			/* 395 */ List<News> newslist = new ArrayList<News>();
			/* 396 */ while (resultSet.next()) {
				/* 397 */ News news = new News();
				/* 398 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/* 399 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 400 */ news.setNewsName(resultSet.getString("news_name"));
				/* 401 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 402 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 403 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 404 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 405 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 406 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 407 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 408 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 409 */ newslist.add(news);
				/*     */ }
			/* 411 */ page = new Page(size.intValue(), totalCount);
			/* 412 */ page.setData(newslist);
			/*     */ }
		/* 414 */ catch (SQLException e) {
			/*     */
			/* 416 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 419 */ JDBCUtil.close(conn, preparedStatement, resultSet);
				/* 420 */ } catch (Exception e) {
				/*     */
				/* 422 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 425 */ return page;
		/*     */ }

	/*     */
	/*     */
	/*     */ public boolean edit(NewsEditForm form) {
		/* 430 */ conn = JDBCUtil.getConnection();
		/* 431 */ preparedStatement = null;
		/* 432 */ int flag = 0;
		/* 433 */ String sql = "UPDATE news_info SET news_name=?, news_content=?, news_keywords=? where news_id = ?";
		/*     */ try {
			/* 435 */ preparedStatement = conn.prepareStatement(sql);
			/* 436 */ preparedStatement.setString(1, form.getNewsName());
			/* 437 */ preparedStatement.setString(2, form.getNewsContent());
			/* 438 */ preparedStatement.setString(3, form.getNewsKeywords());
			/* 439 */ preparedStatement.setInt(4, form.getNewsId().intValue());
			/* 440 */ flag = preparedStatement.executeUpdate();
			/*     */ }
		/* 442 */ catch (SQLException e) {
			/*     */
			/* 444 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 447 */ JDBCUtil.close(conn, preparedStatement);
				/* 448 */ } catch (Exception e) {
				/*     */
				/* 450 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 453 */ return (flag > 0);
		/*     */ }

	/*     */
	/*     */
	/*     */ public boolean click(Integer newsId) {
		/* 458 */ conn = JDBCUtil.getConnection();
		/* 459 */ preparedStatement = null;
		/* 460 */ int flag = 0;
		/* 461 */ String sql = "UPDATE news_info SET news_click = news_click + 1 where news_id = ?";
		/*     */ try {
			/* 463 */ preparedStatement = conn.prepareStatement(sql);
			/* 464 */ preparedStatement.setInt(1, newsId.intValue());
			/* 465 */ flag = preparedStatement.executeUpdate();
			/*     */ }
		/* 467 */ catch (SQLException e) {
			/*     */
			/* 469 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 472 */ JDBCUtil.close(conn, preparedStatement);
				/* 473 */ } catch (Exception e) {
				/*     */
				/* 475 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 478 */ return (flag > 0);
		/*     */ }

	/*     */
	/*     */
	/*     */ public Page pagelist(Integer current, Integer size, String sql, String keyWords) {
		/* 483 */ conn = JDBCUtil.getConnection();
		/* 484 */ preparedStatement = null;
		/* 485 */ resultSet = null;
		/* 486 */ Page page = null;
		/* 487 */ sql = (sql == null) ? "" : sql;
		/* 488 */ String sql1 = "select count(news_id) from news_info where " + sql +
		/* 489 */ " 1=1";
		/*     */
		/* 491 */ String click = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from news_info where "
				+
				/* 492 */ sql +
				/* 493 */ " 1=1 order by news_click desc limit ?,?";
		/*     */
		/* 495 */ String time = "select news_id,u_id,news_name,news_author,news_content,news_type,news_keywords,news_click,news_state,news_del,createtime from news_info where "
				+
				/* 496 */ sql +
				/* 497 */ " 1=1 order by createtime desc limit ?,?";
		/*     */ try {
			/* 499 */ System.out.println("keytwwwww:" + keyWords);
			/* 500 */ int totalCount = 0;
			/* 501 */ preparedStatement = conn.prepareStatement(sql1);
			/* 502 */ resultSet = preparedStatement.executeQuery();
			/* 503 */ while (resultSet.next()) {
				/* 504 */ totalCount = resultSet.getInt(1);
				/*     */ }
			/* 506 */ preparedStatement = keyWords.equals("news_click") ? conn.prepareStatement(click)
					: conn.prepareStatement(time);
			/* 507 */ preparedStatement.setInt(1, (current.intValue() - 1) * size.intValue());
			/* 508 */ preparedStatement.setInt(2, size.intValue());
			/* 509 */ resultSet = preparedStatement.executeQuery();
			/*     */
			/* 511 */ List<News> newslist = new ArrayList<News>();
			/* 512 */ while (resultSet.next()) {
				/* 513 */ News news = new News();
				/* 514 */ news.setNewsId(Integer.valueOf(resultSet.getInt("news_id")));
				/* 515 */ news.setuId(Integer.valueOf(resultSet.getInt("u_id")));
				/* 516 */ news.setNewsName(resultSet.getString("news_name"));
				/* 517 */ news.setNewsAuthor(resultSet.getString("news_author"));
				/* 518 */ news.setNewsContent(resultSet.getString("news_content"));
				/* 519 */ news.setNewsType(Integer.valueOf(resultSet.getInt("news_type")));
				/* 520 */ news.setNewsKeywords(resultSet.getString("news_keywords"));
				/* 521 */ news.setNewsClick(Integer.valueOf(resultSet.getInt("news_click")));
				/* 522 */ news.setNewsState(Integer.valueOf(resultSet.getInt("news_state")));
				/* 523 */ news.setNewsDel(Integer.valueOf(resultSet.getInt("news_del")));
				/* 524 */ news.setCreatetime(resultSet.getTimestamp("createtime"));
				/* 525 */ newslist.add(news);
				/*     */ }
			/* 527 */ page = new Page(size.intValue(), totalCount);
			/* 528 */ page.setData(newslist);
			/*     */ }
		/* 530 */ catch (SQLException e) {
			/*     */
			/* 532 */ e.printStackTrace();
			/*     */ } finally {
			/*     */ try {
				/* 535 */ JDBCUtil.close(conn, preparedStatement, resultSet);
				/* 536 */ } catch (Exception e) {
				/*     */
				/* 538 */ e.printStackTrace();
				/*     */ }
			/*     */ }
		/* 541 */ return page;
		/*     */ }
	/*     */ }

/*
 * Location:
 * /Users/frank/Desktop/admin/WEB-INF/classes/!/cn/zzuisa/news/repository/dao/
 * NewsDAO.class Java compiler version: 8 (52.0) JD-Core Version: 1.0.7
 */